{% extends 'homepage.html' %}
{% block content %}

{% if info.error %}
<div class="announce error">Error: {{  info.error }}</div>

{% elif not info.dimensions %}
<p>Dimension table to be implemented</p>

{% else %}

<p>
  The table shows, for each weight,
  the dimensions of the following subspaces of

  {% if info.group=='Sp8Z' %}
  \(S_k({\rm Sp}(8,Z))\):
  <ul>
    <li><span class="emph">Total</span>: The full space \(S_k({\rm Sp}(8,Z))\).</li>
    <li><span class="emph">Ikeda lifts</span>: The subspace of Ikeda lifts.</li>
    <li><span class="emph">Miyawaki lifts</span>: The subspace of Miyawaki lifts.</li>
    <li><span class="emph">Other</span>: The subspace that are not Ikeda or Miyawaki lifts.</li>
  </ul>

  {% elif info.group=='Kp' %}
  \(S_k({\rm K}({{ info.level }}))\):
  <ul>
    <li><span class="emph">Total</span>: The full space \(S_k({\rm K}({{ info.level }}))\).</li>
    <li><span class="emph">Lifts</span>: The subspace of Gritsenko lifts.</li>
    <li><span class="emph">Nonlifts</span>: The subspace of nonlifts.</li>
  </ul>

  {% else %}
  \({{ info.parent_as_tex }}\):
  <ul>
    <li><span class="emph">Total</span>: The full space
      \({{ info.parent_as_tex }}\).</li>
    <li><span class="emph">Eisenstein</span>: The subspace of Siegel Eisenstein series.</li>
    <li><span class="emph">Klingen</span>: The subspace of Klingen Eisenstein series.</li>
    <li><span class="emph">Maass</span>: The subspace of Maass liftings.</li>
    <li><span class="emph">Interesting</span>: The subspace spanned by cuspidal eigenforms that are not Maass liftings.</li>
  </ul>
  {% endif %}
</p>  

<table>
  <thead>
    <tr>
      {% for header in info.table_headers %}
      <th>{{ header }}</th>
      {% endfor %}
    </tr>
  </thead>
  {% for k,dims in info.dimensions %}
  <tr class = "{{ loop.cycle( 'odd', 'even') }}">
    <td>{{ k }}</td>
    {% for d in dims %}
    <td>{{ d }}</td>
    {% endfor %}
  </tr>
  {% endfor %}
</table>
{% endif %}

<script>
  function validate_weight()
  {
  var input = document.getElementById("weight_range").value;
  if(input == '')
  {  return false;  }
  if(input.match(/^\d+$/))  // Only digits.
  {
  if(input > 1000000)
  {
  alert("Please enter a smaller number.");
  return false;
  }
  else
  {  return true;  }
  }
  else if(input.match(/^\d+\-\d+$/))  // Range, like 2-50
  {
  min_wt = parseInt(input.split("-")[0]);
  max_wt = parseInt(input.split("-")[1]);
  if(min_wt > max_wt)
  {
  alert("Your first weight cannot be larger than the second weight.")
  return false;
  }
  else
  {
  if ((max_wt-min_wt + 1)*max_wt > 1000000)
  {
  alert("Please enter a smaller range (output would take too long to compute).");
  return false;
  }
  else
  {  return true;  }
  }
  }
  else
  {
  alert("Please enter either a weight or a range of weights (in the form '2-50', with no spaces).");
  return false;
  }
  }
</script>

<p>
  {% if info.group=='Sp8Z' %}
  Only weights up to 16 is available.
  {% elif info.group=='Kp' %}
  Enter new prime level and range of weights
  or a weight and a range of levels.
  {% else %}
  Enter a new weight or a range of weights.
  {% endif %}
</p>

<form action="/ModularForm/GSp4/Q" method="get" onSubmit="return validate_weight()"> 
  <input type="hidden" name="group" value="{{ info.group }}" />
  <input type="hidden" name="page" value="dimensions" /> 
  <table> 
    <tr>
      {% if info.group=='Kp' %}
      <td>
	<label>prime level(s)</label>
	<input type="text"
	       name="level"
	       {% if info.level %}value='{{ info.level }}'{% endif %}
	       >
	<span class="formexample">e.g. 3</span>
      </td>
      {% endif %}
      <td> 
	<label>weight(s)</label>
	<input type="text"
	       name="weight_range"
	       {% if info.weight_range %}value='{{ info.weight_range }}'{% endif %}
	       >
	<span class="formexample">e.g. 2 or 20-40</span>
      </td>
      <td> 
	<button type="submit" value="submit">Submit</button>
      </td>
    </tr>
  </table> 
</form> 

{% endblock %}
